import { defineStore } from 'pinia';
import {ref} from 'vue'
// 响应式写法
// export const control1 = defineStore("control",()=>{
//   const isCollapse = ref<boolean>(true)
//   const tagsList = ref([{path:'/dashboard',name:'首页'}])
//   const addTag = (route:any) => {
//     tagsList.value.push(route)
//   }
//   const removeTag = (index:any) => {
//     tagsList.value.splice(index,1)
//   }
//   function closeMenu(){
//     isCollapse.value = !isCollapse.value
//   }
//   return {
//     isCollapse,
//     closeMenu,
//     tagsList,
//     addTag,
//     removeTag
//   }
// })

const control:any = defineStore({
  id:'control',
  state:():any=>{
    const data:any = localStorage.getItem("control")||''
    return{
      tagsList:[{path:'/dashboard',name:'首页'}],
      isCollapse:true,
      dark:true
    }
  },
  actions:{
    removeTag(index:any){
      this.tagsList.splice(index,1)
    },
    closeMenu(){
      this.isCollapse = !this.isCollapse
    },
    addTag(route:any){
      this.tagsList.push(route)
    },
    darkFun(){
      this.dark=!this.dark
    }
  },
  persist: {
    paths: ["tagsList","dark"],
  },
})
export default control